package com.rent.collectrent.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rent.collectrent.entity.RentPlan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author news
 * *@date 2025/9/28
 */
@Mapper
public interface RentPlanMapper extends BaseMapper<RentPlan> {


    /**
     * 根据承租人名称查询待核销的租金计划
     */
    List<RentPlan> selectByTenantName(@Param("tenantName") String tenantName,
                                      @Param("status1") String status1,
                                      @Param("status2") String status2);

    /**
     * 使用乐观锁更新租金计划的收款金额
     */
    int updateWithLock(@Param("id") Long id,
                       @Param("version") Integer version,
                       @Param("interestToWriteOff") BigDecimal interestToWriteOff,
                       @Param("principalToWriteOff") BigDecimal principalToWriteOff);

    /**
     * 批量更新核销状态
     */
    int batchUpdateWriteOffStatus(@Param("ids") List<Long> ids,
                                  @Param("status") RentPlan.WriteOffStatus status);

}
